//
//  IntegralViewController.m
//  AnXin100
//
//  Created by Sakura on 2018/10/31.
//  Copyright © 2018 tzhg. All rights reserved.
//

#import "IntegralViewController.h"
#import "IntegralTableViewCell.h"
@interface IntegralViewController () <UITableViewDelegate, UITableViewDataSource>

@property (nonatomic, strong) UITableView *mainTable;

@property (nonatomic, strong) UIView *incomeView;

@property (nonatomic, strong) UILabel *integralLabel;

@property (nonatomic, strong) UILabel *residueLabel;

@property (nonatomic, strong) UIView *expenditureView;

@end

@implementation IntegralViewController

- (void)viewDidLoad {
    
    [super viewDidLoad];
    self.view.backgroundColor = [UIColor whiteColor];
    _integralLabel = [[UILabel alloc] init];
    _integralLabel.textColor = [UIColor colorWithHex:0xFF9E05];
    _integralLabel.textAlignment = NSTextAlignmentCenter;
    [self.view addSubview:_integralLabel];
    _integralLabel.sd_layout
    .leftEqualToView(self.view)
    .rightEqualToView(self.view)
    .topSpaceToView(self.view, Hn + 15)
    .autoHeightRatio(0);
    _integralLabel.text = @"555积分";

    _residueLabel = [[UILabel alloc] init];
    _residueLabel.textAlignment = NSTextAlignmentCenter;
    _residueLabel.font = [UIFont systemFontOfSize:14];
    [self.view addSubview:_residueLabel];
    _residueLabel.sd_layout
    .leftEqualToView(self.view)
    .rightEqualToView(self.view)
    .topSpaceToView(_integralLabel, 5)
    .autoHeightRatio(0);
    _residueLabel.text = @"剩余积分";
    
    [self.view layoutIfNeeded];
    
    [self.view addSubview:self.mainTable];
    
//    UILabel *incomeLabel = [[UILabel alloc] initWithFrame:CGRectMake(10, CGRectGetMaxY(_residueLabel.frame) + 10, SCREEN_WIDTH - 20, 30)];
//    incomeLabel.text = @"收入";
//    incomeLabel.textColor = [UIColor colorWithHex:0x333333];
//    incomeLabel.font = [UIFont systemFontOfSize:14];
//    [self.view addSubview:incomeLabel];
//
//    _incomeView = [[UIView alloc] initWithFrame:CGRectMake(10, CGRectGetMaxY(incomeLabel.frame) + 10, SCREEN_WIDTH - 20, (SCREEN_HEIGHT - CGRectGetMaxY(incomeLabel.frame) - 100) / 2)];
//    _incomeView.layer.cornerRadius = 10;
//    _incomeView.layer.borderColor = [UIColor colorWithHex:0xE6E6E6].CGColor;
//    _incomeView.layer.borderWidth = 1;
//    [self.view addSubview:_incomeView];
//
//    UILabel *expenditureLabel = [[UILabel alloc] initWithFrame:CGRectMake(10, CGRectGetMaxY(_incomeView.frame) + 10, SCREEN_WIDTH - 20, 30)];
//    expenditureLabel.text = @"支出";
//    expenditureLabel.textColor = [UIColor colorWithHex:0x333333];
//    expenditureLabel.font = [UIFont systemFontOfSize:14];
//    [self.view addSubview:expenditureLabel];
//
//    _expenditureView = [[UIView alloc] initWithFrame:CGRectMake(10, CGRectGetMaxY(expenditureLabel.frame) + 10, SCREEN_WIDTH - 20, _incomeView.mj_h)];
//    _expenditureView.layer.cornerRadius = 10;
//    _expenditureView.layer.borderColor = [UIColor colorWithHex:0xE6E6E6].CGColor;
//    _expenditureView.layer.borderWidth = 1;
//    [self.view addSubview:_expenditureView];
    
}


- (UITableView *)mainTable {
    if (!_mainTable) {
        _mainTable = [[UITableView alloc] initWithFrame:CGRectMake(0, Hn, SCREEN_WIDTH, SCREEN_HEIGHT - Hn) style:UITableViewStylePlain];
        _mainTable.delegate = self;
        _mainTable.dataSource = self;
        [_mainTable registerClass:[IntegralTableViewCell class] forCellReuseIdentifier:@"IntegralTableViewCell"];
        _mainTable.separatorStyle = UITableViewCellSelectionStyleNone;
    }
    return _mainTable;
}

- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView {
    return 2;
}
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
    return 1;
}

- (CGFloat) tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath {
    return 420;
}

- (CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section {
    return 50;
}

- (UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section {
    
    UIView *headView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, SCREEN_WIDTH, 40)];
    UILabel *label = [[UILabel alloc] initWithFrame:CGRectMake(20, 0, SCREEN_WIDTH - 40, 40)];
    label.text = @"收入";
    [headView addSubview:label];
    return headView;
    
}

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
    IntegralTableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"IntegralTableViewCell"];
    cell.textLabel.text = @"2018.09.09兑换商品";
    cell.detailTextLabel.text = @"+120";
    return cell;
}



@end
